@using Microsoft.Extensions.Options;
@using Umbraco.Cms.Api.Management.Controllers.Security
@using Umbraco.Cms.Api.Management.Extensions
@using Umbraco.Cms.Api.Management.Security
@using Umbraco.Cms.Core.Configuration.Models
@using Umbraco.Cms.Core.Hosting
@using Umbraco.Cms.Core.Logging
@using Umbraco.Cms.Core.Mail
@using Umbraco.Cms.Core.Manifest
@using Umbraco.Cms.Core.Serialization
@using Umbraco.Cms.Web.Common.Hosting
@using Umbraco.Extensions
@inject IOptions<GlobalSettings> GlobalSettings
@inject IOptions<SecuritySettings> SecuritySettings
@inject IEmailSender EmailSender
@inject IHostingEnvironment HostingEnvironment
@inject IProfilerHtml ProfilerHtml
@inject IBackOfficeExternalLoginProviders ExternalLogins
@inject IBackOfficePathGenerator BackOfficePathGenerator
@inject IPackageManifestService PackageManifestService
@inject IJsonSerializer JsonSerializer
@{
    bool.TryParse(Context.Request.Query["umbDebug"], out var isDebug);
    var backOfficePath = HostingEnvironment.GetBackOfficePath();
    var loginLogoImage = Url.RouteUrl(BackOfficeGraphicsController.LoginLogoRouteName, new {Version= "1"});
    var loginLogoImageAlternative = Url.RouteUrl(BackOfficeGraphicsController.LoginLogoAlternativeRouteName, new {Version= "1"});
    var loginBackgroundImage = Url.RouteUrl(BackOfficeGraphicsController.LoginBackGroundRouteName, new {Version= "1"});
    var usernameIsEmail = SecuritySettings.Value.UsernameIsEmail;
    var allowUserInvite = EmailSender.CanSendRequiredEmail();
    var allowPasswordReset = SecuritySettings.Value.AllowPasswordReset && EmailSender.CanSendRequiredEmail();
    var disableLocalLogin = ExternalLogins.HasDenyLocalLogin();
}
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<!DOCTYPE html>
<html lang="@GlobalSettings.Value.DefaultUILanguage">
<head>
    <meta charset="UTF-8"/>
    <base href="@backOfficePath.EnsureEndsWith('/')" />
    <link rel="icon" type="image/svg+xml" href="~/umbraco/login/favicon.svg"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta name="mobile-web-app-capable" content="yes"/>
    <meta name="robots" content="noindex, nofollow"/>
    <meta name="pinterest" content="nopin"/>
    <title>Umbraco</title>

    <link rel="stylesheet" href="~/umbraco/backoffice/css/uui-css.css" asp-append-version="true" />
    <style>
      body {
        margin: 0;
        padding: 0;
        background-color: #f4f4f4;
      }
    </style>

    @await Html.BackOfficeImportMapScriptAsync(JsonSerializer, BackOfficePathGenerator, PackageManifestService)
    <script type="module" src="~/umbraco/login/login.js" asp-append-version="true"></script>
</head>

<body class="uui-font uui-text" style="margin: 0; padding: 0; overflow: hidden">
<noscript>
    <style>
        #noscript-container {
            display: flex;
            flex-wrap: wrap;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            padding: 0 20px;
            text-align: center;
        }
    </style>
    <div id="noscript-container">
        <h1 aria-hidden="true" class="uui-h3" style="display: inline-flex; align-items: center; gap: 10px">
            <img alt="logo" src="@loginLogoImageAlternative" style="width: 100%" />
        </h1>
        <p>For full functionality of Umbraco CMS it is necessary to enable JavaScript.</p>
        <p>Here are the <a href="https://www.enable-javascript.com/" target="_blank" rel="noopener" style="text-decoration: underline;">instructions how to enable JavaScript in your web browser</a>.</p>
    </div>
</noscript>

<umb-auth
    return-url="@backOfficePath"
    logo-image="@loginLogoImage"
    logo-image-alternative="@loginLogoImageAlternative"
    background-image="@loginBackgroundImage"
    username-is-email="@usernameIsEmail"
    allow-user-invite="@allowUserInvite"
    allow-password-reset="@allowPasswordReset"
    disable-local-login="@disableLocalLogin">
</umb-auth>

@if (isDebug)
{
    @Html.Raw(ProfilerHtml.Render())
}
</body>
</html>
